﻿using System;

namespace XenAppServices.Classes
{
    /// <summary>
    /// Represents a XenApp Session
    /// </summary>
    public class XASession
    {
        private string userName;
        private string applicationName;
        private string clientName;
        private DateTime logonTime;
        private string serverName;
        private string sessionName;
        private int sessionId;
        private SessionState sessionState;

        /// <summary>
        /// Default constructor
        /// </summary>
        public XASession()
        {
            this.userName = string.Empty;
            this.applicationName = string.Empty;
            this.clientName = string.Empty;
            this.logonTime = DateTime.Now;
            this.serverName = string.Empty;
            this.sessionName = string.Empty;
            this.sessionId = -1;
            this.sessionState = SessionState.Unknown;
        }

        /// <summary>
        /// Username for the session
        /// </summary>
        public string Username 
        { 
            get { return this.userName; } 
            set { this.userName = value; } 
        }

        /// <summary>
        /// Initial application that started the session
        /// </summary>
        public string Application 
        { 
            get { return this.applicationName; } 
            set { this.applicationName = value; } }

        /// <summary>
        /// Client name that initiated the session
        /// </summary>
        public string ClientName 
        { 
            get { return this.clientName; } 
            set { this.clientName = value; } 
        }

        /// <summary>
        /// Initial logon time of the session
        /// Note: if the session was disconnected/reconnected, the logon time will not change
        /// </summary>
        public DateTime LogonTime 
        { 
            get { return this.logonTime; } 
            set { this.logonTime = value; } 
        }

        /// <summary>
        /// XenApp Server name where the session is hosted
        /// </summary>
        public string ServerName 
        { 
            get { return this.serverName; } 
            set { this.serverName = value; } 
        }

        /// <summary>
        /// Name of the session
        /// Example: ICA-tcp#10
        /// </summary>
        public string SessionName 
        { 
            get { return this.sessionName; } 
            set { this.sessionName = value; } 
        }

        /// <summary>
        /// Numerical ID of the session
        /// </summary>
        public int SessionID 
        { 
            get { return this.sessionId; } 
            set { this.sessionId = value; } 
        }

        /// <summary>
        /// Represents the state of the session
        /// See SessionState enum
        /// </summary>
        public SessionState SessionState 
        { 
            get { return this.sessionState; } 
            set { this.sessionState = value; } 
        }

    }

    /// <summary>
    /// Represents a session state
    /// </summary>
    public enum SessionState
    {
        Active,
        Connected,
        Connecting,
        Disconnected,
        Down,
        Idle,
        Init,
        Listening,
        Resetting,
        Shadowing,
        Unknown
    }
}
